package com.firesafe.inspection.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.firesafe.inspection.entity.InspectionEntity;
import com.firesafe.inspection.service.InspectionService;
import com.firesafe.common.utils.PageUtils;
import com.firesafe.common.utils.R;



/**
 * 安全检查记录表
 *
 * @author Liu
 * @email 
 * @date 2024-03-26 16:34:06
 */
@RestController
@RequestMapping("inspection/inspection")
public class InspectionController {
    @Autowired
    private InspectionService inspectionService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = inspectionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		InspectionEntity inspection = inspectionService.getById(id);

        return R.ok().put("inspection", inspection);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody InspectionEntity inspection){
		inspectionService.save(inspection);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody InspectionEntity inspection){
		inspectionService.updateById(inspection);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		inspectionService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
